<?php
defined('_JEXEC') or die(); 
JHTML::_('behavior.tooltip'); 

$listOrder	= @$this->lists['order'];
$listDirn	= @$this->lists['order_Dir'];
$user = &JFactory::getUser();
?>
<script language="javascript" type="text/javascript">
	function submitform(pressbutton)
	{
		var form = document.adminForm ;
	   	if (pressbutton)
	    {
	   	    form.task.value=pressbutton ;
	   	}
	
		if ((pressbutton=='add')||(pressbutton=='publish') ||(pressbutton=='unpublish')||(pressbutton=='remove'))
		{
		  	form.controller.value="profile" ;
		}
		try 
		{
			form.onsubmit();
		}
		catch(e){}
		form.submit();
	}
</script>
<form  id="adminForm" action="<?php echo JRoute::_("index.php?option=com_wrd")?>" method="post" name="adminForm" >
    <div id="editcell">
		<table>
			<tr>
				<td align="left" width="100%">
					<table cellpadding="5">
						<tr>
							<td colspan="7">
		 						<?php echo JText::_( 'Filter' ); ?>:
								<input type="text" name="search" id="search" value="<?php echo $this->search ?>" class="text_area" />
								<button onclick="this.form.submit();"><?php echo JText::_( 'Go' ); ?></button>
								<button onclick="document.getElementById('search').value='';this.form.submit();"><?php echo JText::_( 'Reset' ); ?></button>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
		<table class="table table-striped adminlist">
		<thead>
			<tr>
				<th width="20">
					<?php echo JHtml::_('grid.checkall'); ?>
				</th>
				<th class="title" width="30%">
                	<?php echo JHTML::_('grid.sort',  'Name', 'p.f_name', $listDirn, $listOrder ); ?>
               	</th>
               	<th class="title" width="10%">
                	<?php echo JHTML::_('grid.sort',  'Member ID', 'p.member_id', $listDirn, $listOrder ); ?>
               	</th>
                <th nowrap="nowrap" width="10%">
				   	<?php echo JHTML::_('grid.sort',  'Phone', 'p.phone', $listDirn, $listOrder ); ?>
				</th>
				<th nowrap="nowrap" width="10%">
				   	<?php echo JHTML::_('grid.sort',  'Job', 'p.job',$listDirn, $listOrder ); ?>
				</th> 
				<th nowrap="nowrap" width="10%">
				   	<?php echo JHTML::_('grid.sort',  'Company name', 'p.company_name', $listDirn, $listOrder ); ?>
				</th>
				<th nowrap="nowrap" width="10%">
				   	<?php echo JHTML::_('grid.sort',  'Day of birth', 'p.dob', $listDirn, $listOrder ); ?>
				</th>
				<th nowrap="nowrap" width="10%">
				   	<?php echo JHTML::_('grid.sort',  'Created By', 'p.created_id', $listDirn, $listOrder ); ?>
				</th>
				<th nowrap="nowrap" width="10%">
				   	<?php echo JHTML::_('grid.sort',  'Created Date', 'p.created_date', $listDirn, $listOrder ); ?>
				</th>
				<th nowrap="nowrap" width="10%">
				   	<?php echo JHTML::_('grid.sort',  'Modify by', 'p.modify_by', $listDirn, $listOrder ); ?>
				</th>
				<th nowrap="nowrap" width="10%">
				   	<?php echo JHTML::_('grid.sort',  'Modify date', 'p.modify_date', $listDirn, $listOrder ); ?>
				</th>
				<th nowrap="nowrap" width="10%">
				   	<?php echo JHTML::_('grid.sort',  'Pickup date', 'p.pick_date', $listDirn, $listOrder ); ?>
				</th>
			</tr>
		</thead>
		<tbody>
		<?php
           $k = 0;
		for ($i=0, $n= count( $this->items ); $i < $n; $i++):
			$row = &$this->items[$i];
			$checked 	= JHTML::_('grid.checkedout',   $row, $i);
            $canChange	= $user->authorise('core.edit.state', 'com_wrd.profile.'.$row->id);
			$published 	= JHTML::_('jgrid.published', $row->published, $i,'profile.', $canChange,'cb');
			?>
			<tr class="<?php echo "row$k"; ?>"  >
                <td>
					<?php echo $checked; ?>
				</td>
				<td>
					<a href="index.php?option=com_wrd&controller=profile&id=<?php echo $row->id ?>&layout=form">
						<?php if($row->f_name != '' && $row->l_name != ''):?>
							<?php echo $row->f_name." ".$row->l_name; ?>
						<?php else :?>
							<?php echo $row->email; ?>
						<?php endif;?>
					</a>
				</td>
				<td>
					<?php echo $row->member_id; ?>
				</td>
				<td>
					<?php echo $row->phone; ?>
				</td>
				<td>
					<?php if(!empty($row->job_name)){ echo $row->job_name;} ?>
				</td>
				<td>
					<?php echo $row->company_name; ?>
				</td>
				<td>
					<?php
						$dob = explode('-', $row->dob ) ;
						echo $dob[2]."-".$dob[1]."-".$dob[0]; 
					?>
				</td>
				<td>
					<?php echo $row->created_per; ?>
				</td>
				<td>
					<?php echo $row->created_date; ?>
				</td>
				<td>
					<?php //echo $row->modify_by; ?>
				</td>
				<td>
					<?php //echo $row->modify_date; ?>
				</td>
				<td>
					<?php echo $row->pick_up_date; ?>
				</td>
			</tr>
			<?php
            $k = 1 - $k;
		endfor ;
		?>
		</tbody>

		<tfoot>
			<tr>
				<td colspan="16">
                    <?php
                         echo $this->pagination->getListFooter();
                    ?>
                </td>
			</tr>
		</tfoot>
		</table>
	</div>

	<input type="hidden" name="controller" value="profile" />
	<input type="hidden" name="option" value="com_wrd" />
	<input type="hidden" name="task" value="" />
	<input type="hidden" name="boxchecked" value="0" />
    <input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
    <input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['order_Dir']; ?>" />
	<?php echo JHTML::_( 'form.token' ); ?>
</form>